﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace cart.utils
{
    public class globalID
    {
        public static int getMaxOrderID()
        {
            string SELECT_ORDER_MAX_ID = "select max(orderID) from [order]";
            SqlConnection conn = DB.getSqlConnection();
            int maxProductID = 0;
            DB.connectionOpen(conn);
            SqlCommand cmd = new SqlCommand(SELECT_ORDER_MAX_ID, conn);
            SqlDataReader sdr = cmd.ExecuteReader();
            if (sdr.Read())
            {
                maxProductID = (sdr.IsDBNull(0)) ? 1 : Convert.ToInt32(sdr.GetValue(0));
            }
            maxProductID = maxProductID + 1;
            DB.connectionClose(conn);
            return maxProductID;
        }
    }
}
